from constants import EMPTY_REPLACEMENT
from filters.manager import FilterManager


@FilterManager.register
def append(append: str, value: str):
    return value + append


@FilterManager.register
def capitalize(value: str):
    return value.capitalize()


@FilterManager.register
def downcase(value: str):
    return value.lower()


@FilterManager.register
def upcase(value: str):
    return value.upper()


@FilterManager.register
def split(sep: str, value: str):
    return value.split(sep)


@FilterManager.register
def strip(value: str):
    return value.strip()


@FilterManager.register
def lstrip(value: str):
    return value.lstrip()


@FilterManager.register
def rstrip(value: str):
    return value.rstrip()


@FilterManager.register
def replace(need_replaced: str, replacement: str, value: str):
    return value.replace(need_replaced, replacement)


@FilterManager.register
def replace_first(need_replaced: str, replacement: str, value: str):
    return value.replace(need_replaced, replacement, max=1)


@FilterManager.register
def remove(need_removed: str, value: str):
    return value.replace(need_removed, "")


@FilterManager.register
def remove_first(need_removed: str, value: str):
    return value.replace(need_removed, "", max=1)


@FilterManager.register
def prepend(prepend: str, value: str):
    return prepend + value
